﻿/// <summary>
/// https://leetcode-cn.com/problems/longest-common-prefix/
/// </summary>
public class Solution
{
    public string LongestCommonPrefix(string[] strs)
    {
        Array.Sort(strs);
        string str1 = strs[0];
        string str2 = strs[^1];

        int i = 0;
        for (; i < Math.Min(str1.Length, str2.Length); i++)
        {
            if (str1[i] != str2[i])
                break;
        }
        return str1[..i];
    }
}